package dataConstructions_finished;

import java.util.HashSet;

public class T1 {

    public int[] twoSum(int[] nums, int target) {
        int[] ret = new int[2];
        HashSet<Integer> hashSet = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            hashSet.add(nums[i]);
        }
        for (int i = 0; i < nums.length; i++) {
            int an = target - nums[i];
            if (hashSet.contains(an)) {
                ret[0] = i;
                for (int j = i + 1; j < nums.length; j++) {
                    if (an == nums[j]) {
                        ret[1] = j;
                        return ret;
                    }
                }
            }
        }
        return null;
    }

}
